<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>热学管理平台</title>
	<link rel="stylesheet" href="css/check_box.css">
	<link rel="stylesheet" href="css/index.css" />

	<style>
		.hidden {
			display: none;
		}

		#lang {
			position: fixed;
			right: 0;
			top: 2px;
			cursor: pointer;
		}
	</style>
</head>

<body>
	<a id="lang">English</a>
	<div id="center">
		<div class="login">
			<div class="title" id="title">热学管理平台</div>
			<div class="user-login">
				<form action="/api/login" method="post" id="form">
					<div class="box">
						<div class="user-title name">账号</div>
						<div>
							<input id="user" name="username" />
						</div>
					</div>
					<div class="box">
						<div class="user-title pwd">密码</div>
						<div>
							<input id="password" name="password" type="password" />
						</div>
					</div>
					<div class="box">
						<div class="user-title">验证码</div>
						<div>
							<input style="width: 6rem;" name="code" id="captcha" autocomplete="off" pattern="\d{4}" />
							<!-- <input style="width: 6rem;" name="code" id="captcha" onfocus="isExpired()" autocomplete="off" pattern="\d{4}" /> 付费的接口 -->
						</div>
						<div>
							<img id="code" style="width: 4rem;height: 2rem;border: 1px solid silver;"
								src="/api/captcha.jpg" alt="验证码" title="点我刷新"
								onclick="this.src='/api/captcha.jpg?'+new Date().getTime()" />
						</div>
					</div>
					<div id="msg"></div>
					<div class="labels">
						<label class="checkbox-inline i-checks">
							<input type="checkbox" name="remember-me" />
							<i></i> 记住密码
						</label>
					</div>
					<button id="sub">登录</button>
					<div class="box">
						<p>本平台推荐使用以下浏览器:</p>
						<a href="https://www.google.cn/intl/zh-CN/chrome/" target="_blank" class="google" title="谷歌浏览器">
							<img src="image/google.png" />
						</a>
						<a href="https://www.mozilla.org/zh-CN/firefox/new/" target="_blank" class="firefox"
							title="火狐浏览器">
							<img src="image/firefox.png" />
						</a>
					</div>
				</form>
			</div>
		</div>
	</div>
	<div class="foot">
		<div class="hidden">
			<a href="http://www.hxt5.com">护校通官网</a>
			<a href="https://shop451401809.taobao.com/index.htm?spm=2013.1.w5002-17309633028.2.7b146f57PFRmv3">
				护校通企业店
			</a>
			<a>咨询热线：<span class="phone-number">4000-678-002</span>&nbsp;&nbsp;/&nbsp;&nbsp;<span
					class="phone-number">17875814008</span>&nbsp;&nbsp;(微信同号)</a>
		</div>
		<div class="record-number">
			<a>广州护校通电子科技有限公司版权所有&copy;2006-2019</a>
			<a class="record-number-right" href="http://www.miit.gov.cn" target="_blank">粤ICP备17102741号-1</a>
		</div>
		<div class="police">
			<a href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=44011302002266" target="_blank">
				<img src="image/police-icon.png">&nbsp;&nbsp;粤公网安备&nbsp;&nbsp;44011302002266号
			</a>
		</div>
	</div>
	<script src="./js/jquery-3.2.1.min.js"></script>
	<script>

		function isExpired() {
			var name = $('#user').val();
			sessionStorage['hxt-u']=name
			$.post("/api/pastDue", { username: name }, (e) => {
				if (e.F == "ERROR") {
					// if (confirm('账号已过期，即将跳转续费页面')) {
						alert('账号已过期，即将跳转续费页面')
						location.href = './renewPay.html';
						return false;
					// } else { }
				}
			}, 'json')
		};
		fetch('/api/index_url').then(function (res) {
			return res.text();
		}).then(function (text) {
			if (text) {
				if (/^\//.test(text)) location.href = text;
				else console.log(text);
			}
		});

		if (/micromessenger/.test(navigator.userAgent.toLowerCase())) {
			alert('建议不要在微信中使用本后台系统');
			document.body.innerHTML = '';
		}


		(function () {
			var dg = document.getElementById.bind(document);
			if (/^.{7}com/.test(document.domain)) {
				dg('user').value = 'a';
				dg('password').value = '1';
				return;
			}

			var s = sessionStorage;
			var bg = 'url(/image/background.png)';

			var q = location.search;
			if (q) {
				q = q.substr(1);
				if (q == 'admin' || s['hxt-r']) {
					bg = 'url(/image/background-admin.png)';
					dg('title').innerText = '管理系统';
					s['hxt-r'] = true;
					var list = document.querySelectorAll('.hidden');
					for (var i = 0; i < list.length; i++) {
						list[i].removeAttribute('class');
					}
				}
				dg('msg').innerText = {
					error: '用户名或密码错误',
					code: '验证码错误！', logout: '退出成功！',noAuthority:'账号已停用'
				}[q] || '';
				if (q == 'apk') s['apk'] = true;
			}

			dg('center').style.backgroundImage = bg;

			dg('form').onsubmit = function () {
				s['hxt-u'] = dg('user').value;
				s['hxt-p'] = dg('password').value;
			};

			var u = s['hxt-u'];
			var p = s['hxt-p'];
			if (u) dg('user').value = u;
			if (p) dg('password').value = p;
			s.removeItem('hxt-p');

			dg('lang').onclick = function () {
				fetch('/api/lang/en').then(function (res) {
					localStorage.lang = 'en';
					location.replace('/login_en.html' + location.search);
				});
			};

			if (localStorage.lang == 'en')
				location.replace('/login_en.html' + location.search);
		})();

	</script>


</body>

</html>